package com.edol.painting.utils;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.edol.painting.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by guanrui on 15-1-17.
 */
public class ChangeBgAnimSet {
    private Resources mResources;
    private final int CHANGE_BACKGROUND_FIRST_FRAME = R.drawable.change_bg_anim00;
    private List<Bitmap> mFrames = new ArrayList<Bitmap>();
    private int mCount = Constant.PAINTING_EDIT_CHANGE_BACKGROUND_FRAME;

    public ChangeBgAnimSet(Resources resources) {
        mResources = resources;
    }

    public void initFrames() {
        for (int i = 0; i < mCount; i++) {
            mFrames.add(i, BitmapFactory.decodeResource(mResources, CHANGE_BACKGROUND_FIRST_FRAME + i));
        }
    }

    public List<Bitmap> getFrames() {
        return mFrames;
    }

    public void clear() {
        for (int i = 0; i < mFrames.size(); i++) {
            Bitmap bitmap = mFrames.get(i);
            if (bitmap != null) {
                bitmap.recycle();
                bitmap = null;
            }
        }
    }
}
